/*
* @Author: alvin
* @Date:   2017-02-08
*/
var Api = {
  fetchApi: function (params) {
    var _this = this;
    var Promise = require('es6-promise.min');
    return new Promise((resolve, reject) => {
      wx.request({
        url: params.API_URL,
        data: Object.assign({}, params.data),
        // header: {
        //   'Content-Type': 'application/json'
        // },
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        // method: 'GET',
        method: 'POST',
        success: resolve,
        fail: reject
      })
    })
  },
  result: function (params) {
    var _this = this;
    return _this.fetchApi(params).then(res => res)
  }
}
module.exports = Api;
